import { createSlice } from '@reduxjs/toolkit'

import { AlertColor } from '@mui/material'

type TAlertState = {
	type: AlertColor
	text: string
	isOpen: boolean
}

const initialState: TAlertState = {
	type: 'success',
	text: '',
	isOpen: false,
}

export const alertSlice = createSlice({
	name: 'alert',
	initialState,
	reducers: {
		setType: (state, action) => {
			state.type = action.payload
		},
		setText: (state, action) => {
			state.text = action.payload
		},
		setIsOpen: (state, action) => {
			state.isOpen = action.payload
		},
	},
})
